#!/usr/bin/env python
# -*- coding:utf-8 -*-
from django.shortcuts import HttpResponse,render
from app01 import models
def create_user_group(request):
    models.UserGroup.objects.create(caption='CEO')
    models.UserGroup.objects.create(caption='CTO')
    models.UserGroup.objects.create(caption='COO')
    return HttpResponse('ok')

from app01.forms import forign as ForignForm
def create_user(request):
    obj =ForignForm.CreateUserForm(request.POST)
    if request.method == "POST":
        if obj.is_valid():
            all_data = obj.clean()
            models.User.objects.create(**all_data)
    val = request.GET.get('usergroup')     #url中的usergroup是参数，什么都成
    user_list = models.User.objects.filter(user_group__caption = val)
    return render(request,'forign/create_user.html',{'obj':obj,'user_list':user_list})